function insert(intervals: number[][], newInterval: number[]): number[][] {
    const res=[],arr=[],len=intervals.length;
    let bool=true,i=0
    for(i;i<len;i++){
        if(newInterval[0]<=intervals[i][1]&&newInterval[0]>=intervals[i][0])
    {
        arr.push(intervals[i][0])
        bool=false
    }else if(newInterval[0]>intervals
    [i][1]){
        res.push(intervals[i])
    }else if(newInterval[0]<intervals[i][0]&&bool){
        arr.push(newInterval[0])
        bool=false
    }
    if(newInterval[1]<=intervals[i][1]&&newInterval[1]>=intervals[i][0]){
            arr.push(intervals[i][1])
            res.push(arr)
            i++
            break
        }else if(newInterval[1]<intervals[i][0]){
            arr.push(newInterval[1])
            res.push(arr)
            break
        }
    }
    if(arr.length==1){
        arr.push(newInterval[1])
        res.push(arr)
    }else if(arr.length==0){
        res.push(newInterval)
    }else{
        for(i;i<len;i++){
            res.push(intervals[i])
        }
    }
    return res
};